﻿using System;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using test.Model;

namespace test
{
    public delegate void UpDataArgs(SHowUiEventArgs e);
    
    public partial class Form1 : Form
    {
        UpDataUi myUpData = new UpDataUi();
        UpDataArgs myMainUI;
        Thread myThread;
        public Form1()
        {
            InitializeComponent();
            myUpData.showUiArgs = new UpDataUi.SHowUiArgs(run);
            myMainUI = new UpDataArgs(updateUi);
        }

        private void button_clear_Click(object sender, EventArgs e)
        {
            textBoxMain.Clear();
        }

        private void button_create_Click(object sender, EventArgs e)
        {
            myThread = new Thread(new ThreadStart(myUpData.createOnlyDeviceId));
            myThread.Start();
        }
        public void run(object sender, SHowUiEventArgs e)
        {
            if(this.InvokeRequired)
                this.BeginInvoke(myMainUI,e);
        }
        public void updateUi(SHowUiEventArgs e)
        {
            if (e.judgeException)
                textBoxMain.AppendText("读取下标越界！" + "\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] deviceID:{ " + e.obj.deviceID + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] Manufacturer:{ " + e.obj.Manufacturer + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] deviceModel:{ " + e.obj.deviceModel + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] Release:{ " + e.obj.Release + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] sdkversion:{ " + e.obj.sdkversion + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] resolution:{ " + e.obj.resolution + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] device:{ " + e.obj.device + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] subscriberid:{ " + e.obj.subscriberid + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] mac:{ " + e.obj.mac + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] utdid:{ " + e.obj.utdid + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] networkType:{ " + e.obj.networkType + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] networkOperatorName:{ " + e.obj.networkOperatorName + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] networkOperator:{ " + e.obj.networkOperator + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] appversion:{ " + e.obj.appversion + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] sha1:{ " + e.obj.sha1 + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] applabel:{ " + e.obj.applabel + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] packagename:{ " + e.obj.packagename + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] apikey:{ " + e.obj.apikey + " }\n");
            textBoxMain.AppendText("[" + DateTime.Now.ToString() + "] proxy:{ " + e.obj.proxy + " }\n");

        }

        private void buttonExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
            System.Environment.Exit(0);
        }
    }
    
}
